package com.wdz.controller;

import com.wdz.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author ：Wu Dazhong
 * @Date :2019/6/15
 * @Description:测试控制器
 */
@Controller
public class TestController {
    @RequestMapping("/mytest0")
    public String myTestController0(@RequestBody String jsonString){
        System.out.println(jsonString);
        return jsonString;
    }

    @ResponseBody
    @RequestMapping("/mytest1")
    public String myTestController0(@RequestBody User user){
        System.out.println(user.toString());
        return user.toString();
    }

    @ResponseBody
    @RequestMapping("/mytest3")
    public String myTestController3(@RequestBody User user, @RequestParam("token") String token){
        System.out.println(user.toString());
        System.out.println(token);
        return user.toString();
    }

    @ResponseBody
    @RequestMapping("/mytest5")
    public String myTestController5(@RequestBody User user, @RequestParam("arrays") List<String> arrays){
        System.out.println(user.toString());
        StringBuffer sb = new StringBuffer();
        for (String array : arrays) {
           sb.append(array);
           sb.append(" ");
           System.out.println(array);
        }

        return user.toString()+sb.toString();
    }


}
